function checkFormat(email, username, password, passwordConfirm) {
  if(email != undefined) {
    if(email == '') {
      alert('邮箱为空！');
      return false;
    }else if (!/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(email)) {
      alert('邮箱格式不对！');
      return false;
    }
  }
  if(username != undefined && username == '') {
    alert('用户名为空！');
    return false
  }
  if(password != undefined && password == '') {
    alert('密码为空！');
    return false;
  }
  if(passwordConfirm != undefined) {
    if(passwordConfirm == '') {
      alert('请再次输入密码！');
      return false;
    }else if(passwordConfirm != password) {
      alert('两次输入的密码不一致！');
      return false;
    }
  }
}
/* 使用isLogin之前需要引入operation.js文件 */
function isLogin() {
  let currentPage = window.location.pathname.substring(window.location.pathname.lastIndexOf("/") + 1);
  if(getCookie('id') != null || sessionStorage.getItem('id') != null) {
    /* 已经登录 */
    if(currentPage != 'profile.html') {
      window.location.href = 'profile.html';
    }
  }else {
    if(currentPage != 'login.html') {
      window.location.href = 'login.html';
    }
  }
}